#!/usr/bin/env python
# -*- coding:UTF-8 -*-
from django.db import models

# Create your models here.


class Photos(models.Model):
    photo = models.ImageField(upload_to='static/img', blank=True, verbose_name='事故照片')


class Accident(models.Model):
    recorder = models.CharField(max_length=20, blank=True, verbose_name='记录人')
    recordtime = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='填写时间')
    bridge_name = models.CharField(max_length=50, blank=True, verbose_name='桥梁名称')
    pile = models.CharField(max_length=50, blank=True, verbose_name='桩号位置')
    pile_km = models.IntegerField(blank=True, verbose_name='桩号千米')
    pile_m = models.IntegerField(blank=True, verbose_name='桩号米')
    integrated_position = models.CharField(max_length=200, blank=True, verbose_name='综合位置')
    describe = models.CharField(max_length=100, blank=True, verbose_name='事故描述')
    accident_photos = models.ManyToManyField(Photos, blank=True, verbose_name='事故照片')


class Earthquake(models.Model):                                       # 地震
    bridge_code = models.CharField(max_length=50, blank=True, verbose_name='桥梁编号')
    bridge_name = models.CharField(max_length=50, blank=True, verbose_name='桥梁名称')
    responsible_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    responsible_dept = models.CharField(max_length=50, blank=True, verbose_name='责任单位')
    occur_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='发生时间')
    check_time = models.DateTimeField(auto_now_add=True,  blank=True, null=True, verbose_name='检查时间')
    earthquake_level = models.FloatField(verbose_name='地震等级')
    climate = models.CharField(max_length=20, blank=True, verbose_name='气候')
    wind_level = models.IntegerField(blank=True, null=True, verbose_name='风力等级')


class Flood(models.Model):                                                  # 洪水
    bridge_code = models.CharField(max_length=50, blank=True, verbose_name='桥梁编号')
    bridge_name = models.CharField(max_length=50, blank=True, verbose_name='桥梁名称')
    responsible_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    responsible_dept = models.CharField(max_length=50, blank=True, verbose_name='责任单位')
    check_time = models.DateTimeField(auto_now_add=True,  blank=True, null=True, verbose_name='检查时间')
    start_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='洪水发生开始时间')
    end_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='洪水发生结束时间')
    climate = models.CharField(max_length=20, blank=True, verbose_name='气候')
    wind_level = models.IntegerField(blank=True, null=True, verbose_name='风力等级')
    direction_flow = models.CharField(max_length=20, blank=True, verbose_name='流向')
    flow_rate = models.FloatField(blank=True, verbose_name='流量')
    flow_speed = models.FloatField(blank=True, verbose_name='流速')


class Wind(models.Model):                                           # 风灾
    bridge_code = models.CharField(max_length=50, blank=True, verbose_name='桥梁编号')
    bridge_name = models.CharField(max_length=50, blank=True, verbose_name='桥梁名称')
    responsible_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    responsible_dept = models.CharField(max_length=50, blank=True, verbose_name='责任单位')
    check_time = models.DateTimeField(auto_now_add=True, blank=True, null=True, verbose_name='检查时间')
    start_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='风灾发生开始时间')
    end_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='风灾发生结束时间')
    climate = models.CharField(max_length=20, blank=True, verbose_name='气候')
    wind_level = models.IntegerField(blank=True, null=True, verbose_name='风力等级')
    wind_direction = models.CharField(max_length=20, blank=True, verbose_name='风向')
    average_wind_speed = models.FloatField(blank=True, verbose_name='平均风速')
    max_wind_speed = models.FloatField(blank=True, verbose_name='最大风速')


class Fire(models.Model):                                       # 火灾
    bridge_code = models.CharField(max_length=50, blank=True, verbose_name='桥梁编号')
    bridge_name = models.CharField(max_length=50, blank=True, verbose_name='桥梁名称')
    responsible_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    responsible_dept = models.CharField(max_length=50, blank=True, verbose_name='责任单位')
    check_time = models.DateTimeField(auto_now_add=True, blank=True, null=True, verbose_name='检查时间')
    start_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='火灾发生开始时间')
    end_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='火灾发生结束时间')
    climate = models.CharField(max_length=20, blank=True, verbose_name='气候')
    wind_level = models.IntegerField(blank=True, null=True, verbose_name='风力等级')
    cause = models.CharField(max_length=100, blank=True, verbose_name='火灾原因')
    range = models.CharField(max_length=100, blank=True, verbose_name='影响范围')


class OverweightCar(models.Model):                          # 超重车辆
    bridge_code = models.CharField(max_length=50, blank=True, verbose_name='桥梁编号')
    bridge_name = models.CharField(max_length=50, blank=True, verbose_name='桥梁名称')
    responsible_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    responsible_dept = models.CharField(max_length=50, blank=True, verbose_name='责任单位')
    check_time = models.DateTimeField(auto_now_add=True, blank=True, null=True, verbose_name='检查时间')
    start_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='超重车辆过桥开始时间')
    end_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='超重车辆过桥结束时间')
    climate = models.CharField(max_length=20, blank=True, verbose_name='气候')
    temperature = models.CharField(max_length=20, blank=True, verbose_name='温度')
    wind_level = models.IntegerField(blank=True, null=True, verbose_name='风力等级')
    visibility = models.CharField(max_length=20, blank=True, verbose_name='能见度')
    traffic_rate = models.IntegerField(blank=True, null=True, verbose_name='小时交通量')
    ship_name = models.CharField(max_length=50, blank=True, verbose_name='运达货品名')
    ship_weight = models.FloatField(blank=True, verbose_name='货物重量')
    volume = models.FloatField(blank=True, verbose_name='体积')
    car_type = models.CharField(max_length=50, blank=True, verbose_name='装载车辆型号')
    car_size = models.CharField(max_length=50, blank=True, verbose_name='装载车辆尺寸')
    car_weight = models.FloatField(blank=True, verbose_name='车辆重量')
    shaft_num = models.IntegerField(blank=True, null=True, verbose_name='轴数')
    shaft_distance = models.IntegerField(blank=True, null=True, verbose_name='轴距')
    shaft_weight = models.FloatField(blank=True, verbose_name='轴重')
    wheel_num = models.IntegerField(blank=True, null=True, verbose_name='轮数')
    wheel_distance = models.IntegerField(blank=True, null=True, verbose_name='轮距')
    unit_pressure = models.FloatField(blank=True, verbose_name='单位压力')


class ShipCollision(models.Model):                              # 船舶撞船
    bridge_code = models.CharField(max_length=50, blank=True, verbose_name='桥梁编号')
    bridge_name = models.CharField(max_length=50, blank=True, verbose_name='桥梁名称')
    responsible_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    responsible_dept = models.CharField(max_length=50, blank=True, verbose_name='责任单位')
    check_time = models.DateTimeField(auto_now_add=True, blank=True, null=True, verbose_name='检查时间')
    bump_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='船舶撞击时间')
    ship_tonnage = models.FloatField(blank=True, verbose_name='船舶吨位')
    bump_direction = models.CharField(max_length=50, blank=True, verbose_name='撞击方向')
    bump_force = models.FloatField(blank=True, verbose_name='撞击力')
    climate = models.CharField(max_length=20, blank=True, verbose_name='气候')
    wind_level = models.IntegerField(blank=True, null=True, verbose_name='风力等级')


class ChemicalLiquid(models.Model):                             # 化学液体
    bridge_code = models.CharField(max_length=50, blank=True, verbose_name='桥梁编号')
    bridge_name = models.CharField(max_length=50, blank=True, verbose_name='桥梁名称')
    responsible_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    responsible_dept = models.CharField(max_length=50, blank=True, verbose_name='责任单位')
    check_time = models.DateTimeField(auto_now_add=True, blank=True, null=True, verbose_name='检查时间')
    drain_starttime = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='泄露开始时间')
    drain_endtime = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='泄露结束时间')
    chemical_name = models.CharField(max_length=50, blank=True, verbose_name='化学品名称')
    climate = models.CharField(max_length=20, blank=True, verbose_name='气候')
    range = models.CharField(max_length=100, blank=True, verbose_name='影响范围')


class Detect(models.Model):                                           # 检测明细
    detect_earthquake = models.ForeignKey(Earthquake, blank=True, verbose_name='地震监测')
    detect_flood = models.ForeignKey(Flood, blank=True, verbose_name='洪水监测')
    detect_wind = models.ForeignKey(Wind, blank=True, verbose_name='风灾监测')
    detect_fire = models.ForeignKey(Fire, blank=True, verbose_name='火灾监测')
    detect_overweightcar = models.ForeignKey(OverweightCar, blank=True, verbose_name='超重车辆监测')
    detect_project = models.CharField(max_length=200, blank=True, verbose_name='监测项目')
    detect_content = models.CharField(max_length=200, blank=True, verbose_name='监测内容')
    detect_remark = models.CharField(max_length=200, blank=True, verbose_name='备注信息')


class DiseasePhotos(models.Model):
    photo = models.ImageField(upload_to='static/img', blank=True, verbose_name='应急检查病害照片')


class Check1(models.Model):                                     # 检查明细1
    check_earthquake = models.ForeignKey(Earthquake, blank=True, verbose_name='地震检查')
    check_flood = models.ForeignKey(Flood, blank=True, verbose_name='洪水检查')
    check_wind = models.ForeignKey(Wind, blank=True, verbose_name='风灾检查')
    check_fire = models.ForeignKey(Fire, blank=True, verbose_name='火灾检查')
    check_overweightcar1 = models.ForeignKey(OverweightCar, blank=True, verbose_name='超重车辆过桥前检查')
    check_shipcollision = models.ForeignKey(ShipCollision, blank=True, verbose_name='船舶撞船检查')
    check_chemicalliquid = models.ForeignKey(ChemicalLiquid, blank=True, verbose_name='化学液体检查')
    check_num = models.CharField(max_length=50, blank=True, verbose_name='应急检查编号')
    check_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    check_time = models.DateTimeField(auto_now_add=True, blank=True, null=True, verbose_name='检查时间')
    check_project = models.CharField(max_length=200, blank=True, verbose_name='检查项目')
    disease_type = models.CharField(max_length=50, blank=True, verbose_name='病害类型')
    disease_location = models.CharField(max_length=200, blank=True, verbose_name='病害位置')
    disease_size = models.CharField(max_length=50, blank=True, verbose_name='病害大小')
    disease_degree = models.CharField(max_length=200, blank=True, verbose_name='病害程度')
    state_compare = models.CharField(max_length=200, blank=True, verbose_name='状态比较')
    check_remark = models.CharField(max_length=200, blank=True, verbose_name='备注')
    disease_photo1 = models.ManyToManyField(DiseasePhotos, blank=True, verbose_name='病害照片')


class Chcek2(models.Model):                                     # 检查明细2
    check_overweightcar2 = models.ForeignKey(OverweightCar, blank=True, verbose_name='超重车辆过桥后检查')
    check_num = models.CharField(max_length=50, blank=True, verbose_name='应急检查编号')
    check_person = models.CharField(max_length=50, blank=True, verbose_name='责任人')
    check_time = models.DateTimeField(auto_now_add=True, blank=True, null=True, verbose_name='检查时间')
    check_project = models.CharField(max_length=200, blank=True, verbose_name='检查项目')
    disease_type = models.CharField(max_length=50, blank=True, verbose_name='病害类型')
    disease_location = models.CharField(max_length=200, blank=True, verbose_name='病害位置')
    disease_size = models.CharField(max_length=50, blank=True, verbose_name='病害大小')
    disease_degree = models.CharField(max_length=200, blank=True, verbose_name='病害程度')
    state_compare = models.CharField(max_length=200, blank=True, verbose_name='状态比较')
    check_remark = models.CharField(max_length=200, blank=True, verbose_name='备注')
    disease_photo2 = models.ManyToManyField(DiseasePhotos, blank=True, verbose_name='病害照片')